from sqlalchemy import LargeBinary,create_engine,Column,Integer,String,Text,ForeignKey
import time
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker,relationship,backref
from datetime import datetime

DB_URI='mysql+pymysql://root@127.0.0.1:3306/test?charset=utf8'

engine=create_engine(DB_URI)

Base=declarative_base(engine)#元类编程，将对象转化成元类
session=sessionmaker(engine)()

class Author(Base):
    __tablename__='author'
    id=Column(Integer,autoincrement=True,primary_key=True)
    name=Column(String(20))
    simple=Column(Text)
    img=Column(Text)

class Poem(Base):
    __tablename__='poem'
    id=Column(Integer,autoincrement=True,primary_key=True)
    name=Column(String(200))
    body=Column(Text)
    tags=Column(String(200))
    dynasty=Column(String(20))
    auth=Column(String(20))


if __name__=='__main__':
    Base.metadata.drop_all()
    Base.metadata.create_all()
